package icu.sehnen.controller;


import icu.sehnen.common.CommonResult;
import icu.sehnen.model.NavModel;
import icu.sehnen.service.NavService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@CrossOrigin
@RestController
@RequestMapping("/nav")
public class NavController {
    @Autowired
    NavService navService;
    @GetMapping("/list")
    public CommonResult findAll(){
        List<NavModel> navModelList=navService.findAll();
        return  CommonResult.success(navModelList);
    }

    @GetMapping("/find/{id}")
    public  CommonResult findNavById(@PathVariable Long id){

        NavModel navModel=navService.findNavById(id);
        return  CommonResult.success(navModel);
    }
    @PostMapping("/add")
    public  CommonResult add(NavModel navModel){
          navService.add(navModel);
        return  CommonResult.success();
    }
    @PutMapping("/put/{id}")
    public  CommonResult update(NavModel navModel){
        navService.updateNav(navModel);
        return  CommonResult.success();
    }
    @DeleteMapping("/delete/{id}")
    public  CommonResult delete(@PathVariable Long id){
        navService.delete(id);
        return  CommonResult.success();
    }
}
